package Gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

public class DialogKonfiguracjaWag extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel lblT1 = null;
	private JTextField txtT1 = null;
	private JLabel lblT2 = null;
	private JLabel lblT3 = null;
	private JLabel lblT4 = null;
	private JLabel lblT5 = null;
	private JLabel lblT6 = null;
	private JLabel lblT7 = null;
	private JLabel lblT8 = null;
	private JLabel lblT9 = null;
	private JLabel lblT10 = null;
	private JLabel lblT11 = null;
	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;
	private JLabel jLabel4 = null;
	private JLabel jLabel5 = null;
	private JLabel jLabel6 = null;
	private JLabel jLabel7 = null;
	private JLabel jLabel8 = null;
	private JLabel jLabel9 = null;
	private JTextField txtT2 = null;
	private JTextField txtT3 = null;
	private JTextField txtT4 = null;
	private JTextField txtT5 = null;
	private JTextField txtT6 = null;
	private JTextField txtT7 = null;
	private JTextField txtT8 = null;
	private JTextField txtT9 = null;
	private JTextField txtT10 = null;
	private JTextField txtT11 = null;
	private JLabel jLabel91 = null;
	
	class ZamykanieOkna extends WindowAdapter {
		DialogKonfiguracjaWag okno = null;
		ZamykanieOkna(DialogKonfiguracjaWag okno){
			this.okno = okno;
			
		}
		public void windowClosing(WindowEvent e) {
			
			try {
				wagi[1] = Float.parseFloat(txtT1.getText());
				wagi[2] = Float.parseFloat(txtT2.getText());
				wagi[3] = Float.parseFloat(txtT3.getText());
				wagi[4] = Float.parseFloat(txtT4.getText());
				wagi[5] = Float.parseFloat(txtT5.getText());
				wagi[6] = Float.parseFloat(txtT6.getText());
				wagi[7] = Float.parseFloat(txtT7.getText());
				wagi[8] = Float.parseFloat(txtT8.getText());
				wagi[9] = Float.parseFloat(txtT9.getText());
				wagi[10] = Float.parseFloat(txtT10.getText());
				wagi[11] = Float.parseFloat(txtT11.getText());
				okno.setVisible(false);
			}catch(NumberFormatException ex){
				
				JOptionPane.showMessageDialog(okno, "Niepoprawna wartosc wag. Prosze poprawic.",
						 "Błąd!",JOptionPane.ERROR_MESSAGE);
				okno.setVisible(true);
				okno.toFront();
			}
		}
		
	}
	
	private float[] wagi;

	public float[] getWagi() {
		return wagi;
	}
	/**
	 * @param owner
	 */
	public DialogKonfiguracjaWag(Frame owner) {
		super(owner);
		initialize();
		wagi = new float[12];
		for (int i = 0; i < wagi.length; i++) {
			wagi[i] = 1.0f;
		}
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(347, 358);
		this.setModal(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		this.setTitle("Konfiguracja wag ocen podsumowań");
		this.addWindowListener(new ZamykanieOkna(this));
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel91 = new JLabel();
			jLabel91.setBounds(new Rectangle(140, 294, 183, 16));
			jLabel91.setForeground(Color.gray);
			jLabel91.setText("Length of qualifier");
			jLabel91.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel9 = new JLabel();
			jLabel9.setBounds(new Rectangle(140, 266, 183, 16));
			jLabel9.setForeground(Color.gray);
			jLabel9.setText("Degree of qualifier cardinality");
			jLabel9.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel8 = new JLabel();
			jLabel8.setBounds(new Rectangle(140, 238, 183, 16));
			jLabel8.setForeground(Color.gray);
			jLabel8.setText("Degree of qualifier imprecision");
			jLabel8.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel7 = new JLabel();
			jLabel7.setBounds(new Rectangle(140, 210, 183, 16));
			jLabel7.setForeground(Color.gray);
			jLabel7.setText("Degree of sumarizer cardinality");
			jLabel7.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel6 = new JLabel();
			jLabel6.setBounds(new Rectangle(140, 182, 183, 16));
			jLabel6.setForeground(Color.gray);
			jLabel6.setText("Degree of quantifier cardinality");
			jLabel6.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel5 = new JLabel();
			jLabel5.setBounds(new Rectangle(140, 154, 184, 16));
			jLabel5.setForeground(Color.gray);
			jLabel5.setText("Degree of quantifier imprecision");
			jLabel5.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel4 = new JLabel();
			jLabel4.setBounds(new Rectangle(140, 126, 183, 16));
			jLabel4.setForeground(Color.gray);
			jLabel4.setText("Length of summary");
			jLabel4.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(140, 98, 184, 16));
			jLabel3.setForeground(Color.gray);
			jLabel3.setText("Degree of apprioprateness");
			jLabel3.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(140, 70, 182, 16));
			jLabel2.setForeground(Color.gray);
			jLabel2.setText("Degree of covering");
			jLabel2.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(140, 42, 184, 16));
			jLabel1.setForeground(Color.gray);
			jLabel1.setText("Degree of imprecision");
			jLabel1.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(140, 14, 183, 16));
			jLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
			jLabel.setForeground(Color.gray);
			jLabel.setText("Degree of truth");
			lblT11 = new JLabel();
			lblT11.setBounds(new Rectangle(14, 294, 29, 16));
			lblT11.setText("T11 :");
			lblT10 = new JLabel();
			lblT10.setBounds(new Rectangle(14, 266, 29, 16));
			lblT10.setText("T10 :");
			lblT9 = new JLabel();
			lblT9.setBounds(new Rectangle(14, 238, 29, 16));
			lblT9.setText("T9 :");
			lblT8 = new JLabel();
			lblT8.setBounds(new Rectangle(14, 210, 29, 16));
			lblT8.setText("T8 :");
			lblT7 = new JLabel();
			lblT7.setBounds(new Rectangle(14, 182, 29, 16));
			lblT7.setText("T7 :");
			lblT6 = new JLabel();
			lblT6.setBounds(new Rectangle(14, 154, 29, 16));
			lblT6.setText("T6 :");
			lblT5 = new JLabel();
			lblT5.setBounds(new Rectangle(14, 126, 29, 16));
			lblT5.setText("T5 :");
			lblT4 = new JLabel();
			lblT4.setBounds(new Rectangle(14, 98, 29, 16));
			lblT4.setText("T4 :");
			lblT3 = new JLabel();
			lblT3.setBounds(new Rectangle(14, 70, 29, 16));
			lblT3.setText("T3 :");
			lblT2 = new JLabel();
			lblT2.setBounds(new Rectangle(14, 42, 29, 16));
			lblT2.setText("T2 :");
			lblT1 = new JLabel();
			lblT1.setBounds(new Rectangle(16, 16, 27, 16));
			lblT1.setText("T1 :");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(lblT1, null);
			jContentPane.add(getTxtT1(), null);
			jContentPane.add(lblT2, null);
			jContentPane.add(lblT3, null);
			jContentPane.add(lblT4, null);
			jContentPane.add(lblT5, null);
			jContentPane.add(lblT6, null);
			jContentPane.add(lblT7, null);
			jContentPane.add(lblT8, null);
			jContentPane.add(lblT9, null);
			jContentPane.add(lblT10, null);
			jContentPane.add(lblT11, null);
			jContentPane.add(jLabel, null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(jLabel2, null);
			jContentPane.add(jLabel3, null);
			jContentPane.add(jLabel4, null);
			jContentPane.add(jLabel5, null);
			jContentPane.add(jLabel6, null);
			jContentPane.add(jLabel7, null);
			jContentPane.add(jLabel8, null);
			jContentPane.add(jLabel9, null);
			jContentPane.add(getTxtT2(), null);
			jContentPane.add(getTxtT3(), null);
			jContentPane.add(getTxtT4(), null);
			jContentPane.add(getTxtT5(), null);
			jContentPane.add(getTxtT6(), null);
			jContentPane.add(getTxtT7(), null);
			jContentPane.add(getTxtT8(), null);
			jContentPane.add(getTxtT9(), null);
			jContentPane.add(getTxtT10(), null);
			jContentPane.add(getTxtT11(), null);
			jContentPane.add(jLabel91, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes txtT1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT1() {
		if (txtT1 == null) {
			txtT1 = new JTextField();
			txtT1.setBounds(new Rectangle(49, 14, 85, 20));
			txtT1.setText("1.0");
			txtT1.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT1;
	}

	/**
	 * This method initializes txtT2	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT2() {
		if (txtT2 == null) {
			txtT2 = new JTextField();
			txtT2.setBounds(new Rectangle(49, 42, 85, 20));
			txtT2.setText("1.0");
			txtT2.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT2;
	}

	/**
	 * This method initializes txtT3	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT3() {
		if (txtT3 == null) {
			txtT3 = new JTextField();
			txtT3.setBounds(new Rectangle(49, 69, 85, 20));
			txtT3.setText("1.0");
			txtT3.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT3;
	}

	/**
	 * This method initializes txtT4	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT4() {
		if (txtT4 == null) {
			txtT4 = new JTextField();
			txtT4.setBounds(new Rectangle(49, 97, 85, 20));
			txtT4.setText("1.0");
			txtT4.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT4;
	}

	/**
	 * This method initializes txtT5	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT5() {
		if (txtT5 == null) {
			txtT5 = new JTextField();
			txtT5.setBounds(new Rectangle(49, 126, 85, 20));
			txtT5.setText("1.0");
			txtT5.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT5;
	}

	/**
	 * This method initializes txtT6	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT6() {
		if (txtT6 == null) {
			txtT6 = new JTextField();
			txtT6.setBounds(new Rectangle(49, 154, 85, 20));
			txtT6.setText("1.0");
			txtT6.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT6;
	}

	/**
	 * This method initializes txtT7	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT7() {
		if (txtT7 == null) {
			txtT7 = new JTextField();
			txtT7.setBounds(new Rectangle(49, 181, 85, 20));
			txtT7.setText("1.0");
			txtT7.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT7;
	}

	/**
	 * This method initializes txtT8	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT8() {
		if (txtT8 == null) {
			txtT8 = new JTextField();
			txtT8.setBounds(new Rectangle(49, 210, 85, 20));
			txtT8.setText("1.0");
			txtT8.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT8;
	}

	/**
	 * This method initializes txtT9	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT9() {
		if (txtT9 == null) {
			txtT9 = new JTextField();
			txtT9.setBounds(new Rectangle(49, 238, 85, 20));
			txtT9.setText("1.0");
			txtT9.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT9;
	}

	/**
	 * This method initializes txtT10	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT10() {
		if (txtT10 == null) {
			txtT10 = new JTextField();
			txtT10.setBounds(new Rectangle(49, 266, 85, 20));
			txtT10.setText("1.0");
			txtT10.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT10;
	}

	/**
	 * This method initializes txtT11	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtT11() {
		if (txtT11 == null) {
			txtT11 = new JTextField();
			txtT11.setBounds(new Rectangle(49, 294, 85, 20));
			txtT11.setText("1.0");
			txtT11.setHorizontalAlignment(JTextField.RIGHT);
		}
		return txtT11;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
